import {contextBridge, ipcRenderer} from 'electron'
// import { electronAPI } from '@electron-toolkit/preload'
import {manageApi} from './manageApi'

// Use `contextBridge` APIs to expose Electron APIs to
// renderer only if context isolation is enabled, otherwise
// just add to the DOM global.
console.log("process.contextIsolated", process.contextIsolated);
if (process.contextIsolated) {
  try {
    // contextBridge.exposeInMainWorld('electron', electronAPI)
    contextBridge.exposeInMainWorld('manageApi', manageApi)
  } catch (error) {
    console.error(error)
  }
} else {
  // @ts-ignore (define in dts)
  // window.electron = electronAPI
  // @ts-ignore (define in dts)
  window.manageApi = manageApi
}

require('electron').ipcRenderer.on('zoomFactor', function (event, message) {
  console.log("message===>", message);
  document.getElementsByTagName("html")[0].style['font-size'] = (15 * message) + "px"
});
